package com.hdu.point_offer;

public class lcr148 {
    class Solution {
        public boolean validateBookSequences(int[] putIn, int[] takeOut) {
            int len = putIn.length;
            int[] stack = new int[len];
            int stackTop = 0;
            int outIndex = 0;
            for (int i = 0; i < len; i++)
            {
                stack[stackTop++] = putIn[i];
                while (outIndex < len && stackTop > 0 && stack[stackTop - 1] == takeOut[outIndex])
                {
                    stackTop--;
                    outIndex++;
                }
            }
            return stackTop == 0;
        }
    }
}
